<?php

namespace app\common\library;

use app\admin\model\scanwork\Config as ConfigModel;

/**
 * scanwork配置读取类
 */
class ScanworkConfig
{
    /**
     * 获取配置值
     */
    public static function get($key, $default = '')
    {
        return ConfigModel::getValue($key, $default);
    }
    
    /**
     * 设置配置值
     */
    public static function set($key, $value)
    {
        return ConfigModel::setValue($key, $value);
    }
    
    /**
     * 获取网站域名
     */
    public static function getSiteDomain()
    {
        return ConfigModel::getSiteDomain();
    }
    
    /**
     * 获取溯源码URL
     */
    public static function getTraceUrl($traceCode)
    {
        return ConfigModel::getTraceUrl($traceCode);
    }
    
    /**
     * 获取报工二维码URL
     */
    public static function getReportQrUrl($allocationId)
    {
        return ConfigModel::getReportQrUrl($allocationId);
    }
    
    /**
     * 获取完整图片URL
     */
    public static function getFullImageUrl($imagePath)
    {
        return ConfigModel::getFullImageUrl($imagePath);
    }
    
    /**
     * 获取小程序配置
     */
    public static function getMiniappConfig()
    {
        return [
            'appid' => self::get('miniapp_appid'),
            'secret' => self::get('miniapp_secret'),
            'name' => self::get('miniapp_name', '生产管理小程序')
        ];
    }
    
    /**
     * 获取七牛云配置
     */
    public static function getQiniuConfig()
    {
        return [
            'access_key' => self::get('qiniu_access_key'),
            'secret_key' => self::get('qiniu_secret_key'),
            'bucket' => self::get('qiniu_bucket'),
            'domain' => self::get('qiniu_domain'),
            'enabled' => self::get('qiniu_enabled', '0') == '1'
        ];
    }
}
